﻿/// <reference path="jquery-1.3.2.js" />
/// <reference path="json.js" />

$(document).ready(load);
function load() {
    $("#_btnSayHi").bind("click", sayHi);
    $("#_btnGetUser").bind("click", getUser);
    //$("#_btnGetThread").bind("click", getThread);
    $("#_btnRemoveCache").bind("click", removeCache);
}
function sayHi() {
    var data = { Name: $("#_tbSayHi").val() };
    $.ajax({
        type: "GET",
        url: "DataServices/UserService.ashx/SayHi",
        data: data,
        dataType: "text/plain",
        success: function(msg) {
            $("#_sayHi").html(msg);
        }
    });
}
function getUser() {
    var data = { Id: 1 };
    $.ajax({
        contentType: "application/json",
        type: "POST",
        url: "DataServices/UserService.ashx/GetUser",
        data: JSON2.stringify(data),
        dataType: "json",
        success: function(user) {
            var msg = "Hi! My name is " + user.Name + ". I'm currently a " + user.Job + " attending " + user.School;
            $("#_getUser").html(msg);
        }
    });
}

function getThread() {
    $.ajax({
        type: "POST",
        url: "DataServices/UserService.ashx/GetThread",
        data: {},
        dataType: "text",
        success: function(user) {
            alert(user);
        }
    });
}

function removeCache() {
    $.ajax({
        type: "POST",
        url: "DataServices/UserService.ashx/RemoveCache",
        data: {  },        
        success: function() {
            alert("Cache has been removed");
        }

    });
}